package com.endurance.config;

import org.springframework.cloud.gateway.filter.factory.GatewayFilterFactory;
import org.springframework.cloud.gateway.handler.predicate.RoutePredicateFactory;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ProjectName: spring-cloud-hoxton-parent
 * @Package: com.endurance.config
 * @ClassName: GatewayConfig
 * @Description:
 * @Author: sunlin
 * @CreateDate: 2024/02/08 14:35
 * @Version: 1.0
 */
//@Configuration
public class GatewayConfig {
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
         return builder.routes()
                // 函数式接口
                .route("categories_route", r -> r.path("/categories/**")
                        .uri("http://localhost:8998"))
                .route("videos_route", r -> r.path("/videos/**")
                        .uri("http://localhost:8999"))
                .build();
    }
}